package com.ytjj.qmyx.admin.service.impl;

import com.github.pagehelper.PageHelper;
import com.ytjj.common.api.CommonPage;
import com.ytjj.qmyx.admin.model.request.PbRequest;
import com.ytjj.qmyx.admin.service.PbService;
import com.ytjj.qmyx.mall.mapper.PbMapper;
import com.ytjj.qmyx.mall.model.Pb;
import com.ytjj.qmyx.mall.model.PbExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PbServiceImpl implements PbService {

    @Resource
    private PbMapper pbMapper;
    @Override
    public CommonPage selectList(PbRequest pbRequest) {
        PageHelper.startPage(pbRequest.getPageNum(),pbRequest.getPageSize());
        PbExample pbExample = new PbExample();
        List<Pb> pds = pbMapper.selectByExample(pbExample);
        //List<Pb> pds = pbDao.SelectList();
        return CommonPage.restPage(pds);
    }

    @Override
    public Integer update(Pb pb) {
        int count = pbMapper.updateByPrimaryKeySelective(pb);
        return count;
    }

    @Override
    public Integer add(Pb pb) {
        int count = pbMapper.insert(pb);
        return count;
    }

    @Override
    public Integer delete(PbRequest pbRequest) {
        int count = pbMapper.deleteByPrimaryKey(pbRequest.getPbId());
        return count;
    }

    @Override
    public Pb selectByPbId(Integer pbid) {
        Pb pb = pbMapper.selectByPrimaryKey(pbid);
        return pb;
    }
}
